// entities/user.entity.ts

import { Column, Entity, OneToMany, PrimaryGeneratedColumn, ManyToOne } from "typeorm";
import { Post } from "./post.entity";
import { Check } from './check.entity'
import { Roles } from './roles.entity'
import { Exclude } from 'class-transformer';

@Entity("user")
export class User {
    // 自增唯一主键
    @PrimaryGeneratedColumn()
    id: number;

    // 账户名类型
    @Column()
    account: string;

    // 密码
    @Column()
    @Exclude() // 排除密码字段
    password: string;

    // 用户名
    @Column()
    username: string;

    // 用户管理考勤 多个考勤对应一个用户
    @OneToMany(type => Check, check => check.user)
    posts: Post[];
    checks: Check[];

    //一个角色对应多个用户
    // @ManyToOne(type => Roles, roles => roles.users, {
    //     cascade: true,// 自动保存相关对象
    //     onDelete: 'CASCADE'
    // })

    // users: Roles[]


    @Column()
    roles: string;
}